Skip to content

feat: add GetWithAssistedSupport for Company endpoint 202 handling#392

Open
travisjoseph wants to merge 1 commit intomainfrom
fix/company-202-response-handling
Open

feat: add GetWithAssistedSupport for Company endpoint 202 handling#392
travisjoseph wants to merge 1 commit intomainfrom
fix/company-202-response-handling

Conversation

@travisjoseph
Copy link
Copy Markdown

Summary

  • Adds GetWithAssistedSupport() method to handle 202 responses from assisted connections
  • Implements union response type (Company | CompanyDataSyncInProgress)
  • Follows existing PayStatement pattern for union discrimination
  • Non-generated file won't be overwritten by codegen

Problem

For assisted connections, /employer/company endpoint returns 202 status when data sync is in progress. Current SDK only expects Company struct, causing deserialization failures.

Solution

Created company_assisted.go with union response types:

  • Company variant for 200 OK with data
  • CompanyDataSyncInProgress variant for 202 sync status
  • Type-safe pattern matching via AsUnion() method

Usage

resp, err := client.HRIS.Company.GetWithAssistedSupport(ctx)
switch u := resp.AsUnion().(type) {
case finchgo.Company:
    // Process company data
case finchgo.CompanyDataSyncInProgress:
    // Retry later - data syncing
}

Test Plan

  • ✅ Unit tests for 200 response (deserializes to Company)
  • ✅ Unit tests for 202 response (deserializes to CompanyDataSyncInProgress)
  • ✅ Example program demonstrating usage pattern
  • ✅ All existing tests still pass (verified internal package tests)

🤖 Generated with Claude Code

For assisted connections, the /employer/company endpoint returns 202
status when data sync is in progress. This creates a non-generated
wrapper that handles both response types via union discrimination:

- Company (200 OK with company data)
- CompanyDataSyncInProgress (202 with sync status)

Implementation follows existing PayStatement pattern with:
- Union response type with AsUnion() method
- Type-safe pattern matching via type switch
- Constants for 202 status codes and messages
- Full test coverage for both response types

Usage:
```go
resp, err := client.HRIS.Company.GetWithAssistedSupport(ctx)
switch u := resp.AsUnion().(type) {
case finchgo.Company:
    // Handle company data
case finchgo.CompanyDataSyncInProgress:
    // Retry later
}
```

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant